package fr.enssat.embeddedsoft.projet.sumo.abouzidi.mndiaye;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

public class ArenaView extends View {
	static final String TAG = "AreneView";
	
	private Cercle grandCercle;
	private Cercle sumoUn;
	private Cercle sumoDeux;
	
	public ArenaView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init();
	}

	public ArenaView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public ArenaView(Context context) {
		super(context);
		init();
	}

	public void init() {
		grandCercle = new Cercle(100,Color.GRAY);
		sumoUn = new Cercle(15,Color.BLUE);
		sumoDeux = new Cercle(15,Color.RED);		
	}
	
	public void setSumoUnPlace(int x, int y) {
			sumoUn.setX(x-60);
			sumoUn.setY(y);
			invalidate();		
	}
	
	public void setSumoDeuxPlace(int x, int y) {
		sumoDeux.setX(x+70);
		sumoDeux.setY(y);
		invalidate();
	}
	
	@Override
	protected void onSizeChanged(int w, int h, int oldw, int oldh) {
		// TODO Auto-generated method stub
		super.onSizeChanged(w, h, oldw, oldh);
		
		Log.d(TAG,"("+w+", "+h+")");
		
		// set grandCercle place
		grandCercle.setX(w/2);
		grandCercle.setY(h/2);
		setSumoUnPlace((w+oldw)/2, (h+oldh)/2);
		setSumoDeuxPlace((w-oldw)/2, (h-oldh)/2);
		
	}
	
	
	
	
	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		grandCercle.draw(canvas);
		sumoUn.draw(canvas);
		sumoDeux.draw(canvas);
	}
	
}
